home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1733 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.6 KB

  1. Path: uni-erlangen.de!winx03!sunshine!schoof
  2. From: schoof@informatik.uni-wuerzburg.de (Jochen Schoof)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q: realloc->free?
  5. Date: 16 Jan 1996 15:52:38 GMT
  6. Organization: University of Wuerzburg, Germany
  7. Message-ID: <4dghk7$d57@winx03.informatik.uni-wuerzburg.de>
  8. References: <4daa2e$oh5@axe.netdoor.com> <4de8uv$48j@bs33n.staffs.ac.uk>
  9. NNTP-Posting-Host: wi2x01.informatik.uni-wuerzburg.de
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Wildfire (cm4bctrd@bs47c.staffs.ac.uk) wrote:
  13. : Right.  I could be wrong in what I'm about to say, but I *think* this is 
  14. : correct.
  15.  
  16. If you have any doubt about the correctness of you post - DON'T POST!
  17.  
  18. : If you think about it, there is no need for realloc() to move the *start* 
  19. : of the allocated memory - it may need to make a link between the end of 
  20. : the original memory block and the start of an extension block, but that's 
  21. : different.
  22.  
  23. This is one solution of doing it (and let me add it is a strange one),
  24. but no one guarantees that some machine uses this technique. The machine
  25. and operating system I'm using always provide one single block of
  26. memory when using any member of the malloc()-family - and so do most
  27. systems.
  28.  
  29. : So b is either going to be NULL or a.
  30.  
  31. Speaking for realloc() in general this is complete nonsense.
  32.  
  33. : realloc() does no free()ing, as far as I know, since the contents of 
  34. : memory are unchanged.
  35.  
  36. This is wrong, too. It is even possible, that realloc moves the contents
  37. of the old memory block if you call realloc() with the exact size of the
  38. block. On most UNIX system doubling or halving the size of a memory
  39. block will result in its contents being moved.
  40.  
  41. : I would really like someone who properly knows about this to confirm or 
  42. : correct what I'm saying.
  43.  
  44. The details are highly system specific and therefore should not be dis-
  45. cussed in comp.lang.c  You'll only get information on what your realloc()
  46. does by reading your compiler's documentation. The general part is covered
  47. in K&R2 on page 252 (I finally got an English version).
  48.  
  49. - Jochen
  50.  
  51. --
  52. --------------------------------------------------------------------------
  53.  Jochen Schoof                  mailto:schoof@informatik.uni-wuerzburg.de
  54.  Lehrstuhl fuer Informatik II +-------------------------------------------
  55.  Universitaet Wuerzburg       | You are just reading a .sig-light:
  56.  D-97074 Wuerzburg (Germany)  | It is free of fat, sugar and cholesterol!
  57. ------------------------------+-------------------------------------------
  58.  WWW-Homepage:        http://www.informatik.uni-wuerzburg.de/staff/joscho
  59. --------------------------------------------------------------------------
  60.